import time

from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction

url = "http://127.0.0.1:4723/wd/hub"

param = {
    "deviceName": "6f3d92e1",  # 设备号
    "platformName": "Android",  # 系统名称
    "platformVersion": "13",  # 系统版本
    "appPackage": "com.chinamworld.main",  # 软件包名
    "appActivity": "com.ccb.start.MainActivity"  # 启动类名
}

driver = webdriver.Remote(url, param)
'''
    增强：
    1.导包
    2.加入合适的等待方式
    3.使用适合app移动端的定位方式,MobileBy

'''

el1 = driver.find_element(MobileBy.ACCESSIBILITY_ID,"同意")
el1.click()
TouchAction(driver).tap(x=1281, y=408).perform()
el2 = driver.find_element(MobileBy.XPATH,"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.slidingpanelayout.widget.SlidingPaneLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[1]/android.view.View/android.view.View[2]/android.view.View/android.view.View[1]/android.view.View/android.view.View[1]/android.widget.TextView")
el2.click()
time.sleep(40)
#明细
el3 = driver.find_element(MobileBy.XPATH,"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout[1]/android.widget.LinearLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[3]/android.view.View/android.widget.TextView[3]")
el3.click()
